package indi.luckly.controller;

import indi.luckly.common.request.QueryUserInfoParams;
import indi.luckly.common.request.UpDateUserInfoParams;
import indi.luckly.common.response.QueryUserBaseInfoResponseData;
import indi.luckly.common.response.ResponseResult;
import indi.luckly.mapper.IPermissionMapper;
import indi.luckly.service.IUserService;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * 查询用户信息
 */

@RestController
@RequestMapping("/user")
@Slf4j
public class UserController {

    @Autowired
    @Qualifier("UserService")
    private IUserService mUserService;

    @Autowired
    @Qualifier("PermissionMapper")
    private IPermissionMapper permissionMapper;


    @SneakyThrows
    @PostMapping()
    @RequestMapping(path = "/queryUserInfo", method = RequestMethod.POST)
    public ResponseResult<QueryUserBaseInfoResponseData> queryUserInfo() {
        String number;
        Subject subject = SecurityUtils.getSubject();
        subject.getPrincipal();
        return ResponseResult.ok(mUserService.queryUserInfo(""));
    }

    @SneakyThrows
    @PostMapping()
    @RequestMapping(path = "/upDateUserInfo", method = RequestMethod.POST)
    public ResponseResult<?> upDateUserInfo(@RequestBody UpDateUserInfoParams params) {
        mUserService.upDateUserInfo(params);
        return ResponseResult.ok();
    }
}
